package com.zyg.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zyg.pojo.Cladd;
import com.zyg.pojo.Grade;
import com.zyg.pojo.Hostel;
import com.zyg.pojo.Stu;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StuMapper extends BaseMapper<Stu> {

    @Override
    @Select("select stu_id,stu_name,grade_id,cladd_id,hostel_id from sys_stu ${ew.customSqlSegment}")
    @Results({
            @Result(property = "stuId", column = "stu_id"),
            @Result(property = "stuName", column = "stu_name"),
            @Result(property = "grade", column = "grade_id", javaType = Grade.class,
                    one = @One(select = "com.zyg.dao.GradeMapper.selectById")),
            @Result(property = "cladd", column = "cladd_id", javaType = Cladd.class,
                    one = @One(select = "com.zyg.dao.CladdMapper.selectById")),
            @Result(property = "hostel", column = "hostel_id", javaType = Hostel.class,
                    one = @One(select = "com.zyg.dao.HostelMapper.selectById"))
    })
    List<Stu> selectList(IPage<Stu> page, @Param(Constants.WRAPPER)Wrapper<Stu> queryWrapper);
}